//自定义扩展
var $h={
		post:function(){//统一处理post请求
			var url="",param={},fun=function(){};
			for (var i = 0; i < arguments.length; i++) {
				if("string"==typeof(arguments[i])){
					url = arguments[i];
				}else if("object"==typeof(arguments[i])){
					param = arguments[i];
				}else if("function"==typeof(arguments[i])){
					fun = arguments[i];
				}
			}
			$.post(url,param,function(json){
				if(json.code==2){//尚未登陆，跳转到登陆页面
					alert("你尚未登录，将回到登录页面！");
					top.location.href = "/login.html";
				}else{
					fun(json);
				}
			});
		},
		ajaxSubmit:function(){//统一处理submit请求
			var form = arguments[0],param = arguments[1];
			var backfunction = param.success;
			param.success = function(json){
				if(json.code==2){//尚未登陆，跳转到登陆页面
					alert("你尚未登录，将回到登录页面！");
					top.location.href = "/login.html";
				}else{
					backfunction(json);
				}
			}
			form.ajaxSubmit(param); 
		}
};
/*---来自drag.js begin---------------*/
var dialogZindex = 1;
$.fn.extend({
		//---元素拖动插件
    dragging:function(data){   
		var $this = $(this);
		var xPage;
		var yPage;
		var X;//
		var Y;//
		var xRand = 0;//
		var yRand = 0;//
		var father = $this.parent();
		var defaults = {
			move : 'both',
			randomPosition : true ,
			hander:1,
			moveOutEnable:true
		}
		var opt = $.extend({},defaults,data);
		var movePosition = opt.move;
		var random = opt.randomPosition;
		var moveOutEnable = opt.moveOutEnable;
		var hander = opt.hander;
		
		if(hander == 1){
			hander = $this; 
		}else{
			hander = $this.find(opt.hander);
		}
		
			
		//---初始化
		father.css({"position":"relative","overflow":"hidden"});
		$this.css({"position":"absolute"});
		hander.css({"cursor":"default"});

		var faWidth = father.width();
		var faHeight = father.height();
		var thisWidth = $this.width()+parseInt($this.css('padding-left'))+parseInt($this.css('padding-right'))+parseInt($this.css('border-left-width'))+parseInt($this.css('border-right-width'));
		var thisHeight = $this.height()+parseInt($this.css('padding-top'))+parseInt($this.css('padding-bottom'))+parseInt($this.css('border-top-width'))+parseInt($this.css('border-bottom-width'));
		
		var mDown = false;//
		var positionX;
		var positionY;
		var moveX ;
		var moveY ;
		
		if(random){
			$thisRandom();
		}
		function $thisRandom(){ //随机函数
			$this.each(function(index){
				var randY = parseInt(Math.random()*(faHeight-thisHeight));///
				var randX = parseInt(Math.random()*(faWidth-thisWidth));///
				if(movePosition.toLowerCase() == 'x'){
					$(this).css({
						left:randX
					});
				}else if(movePosition.toLowerCase() == 'y'){
					$(this).css({
						top:randY
					});
				}else if(movePosition.toLowerCase() == 'both'){
					$(this).css({
						top:randY,
						left:randX
					});
				}
				
			});	
		}
		
		
		hander.mousedown(function(e){
			position_init(e);
		});
		hander.find("span").mousedown(function(e){
			position_init(e);
		});
		function position_init(e){
			$this.css({"zIndex":$this.css("z-index")==dialogZindex?dialogZindex:++dialogZindex});
			mDown = true;
			X = e.pageX;
			Y = e.pageY;
			positionX = $this.position().left;
			positionY = $this.position().top;
		}
			
		$(document).mouseup(function(e){
			mDown = false;
		});
		
		$(document).mousemove(function(e){
			faWidth = father.width();
			faHeight = father.height();
			thisWidth = $this.width()+parseInt($this.css('padding-left'))+parseInt($this.css('padding-right'))+parseInt($this.css('border-left-width'))+parseInt($this.css('border-right-width'));
			thisHeight = $this.height()+parseInt($this.css('padding-top'))+parseInt($this.css('padding-bottom'))+parseInt($this.css('border-top-width'))+parseInt($this.css('border-bottom-width'));
			xPage = e.pageX;//--
			moveX = positionX+xPage-X;
			
			yPage = e.pageY;//--
			moveY = positionY+yPage-Y;
			
			function thisXMove(){ //x轴移动
				if(mDown == true){
					$this.css({"left":moveX});
				}else{
					return;
				}
				if(moveX < 0){
					$this.css({"left":"0"});
				}
				if(moveX > (faWidth-thisWidth)){
					$this.css({"left":faWidth-thisWidth});
				}
				return moveX;
			}
			
			function thisYMove(){ //y轴移动
				if(mDown == true){
					$this.css({"top":moveY});
				}else{
					return;
				}
				if(moveY < 0){
					$this.css({"top":"0"});
				}
				if(moveY > (faHeight-thisHeight)){
					$this.css({"top":faHeight-thisHeight});
				}
				return moveY;
			}

			function thisAllMove(){ //全部移动
				if(mDown == true){
					$this.css({"left":moveX,"top":moveY});
				}else{
					return;
				}
				if(moveX < 0){
					$this.css({"left":"0"});
				}
				if(moveX > (faWidth-thisWidth)){
					$this.css({"left":faWidth-thisWidth});
				}

				if(moveY < 0){
					$this.css({"top":"0"});
				}
				if(moveY > (faHeight-thisHeight)){
					$this.css({"top":faHeight-thisHeight});
				}
			}
			function thisAllMoveOutEnable(){ //全部移动 边界可以超过屏幕
				if(mDown == true){
					$this.css({"left":moveX,"top":moveY});
				}else{
					return;
				}
				if(xPage < 0){
					$this.css({"left":positionX-X});
				}
				if(xPage > faWidth){
					$this.css({"left":faWidth+positionX-X});
				}
				if(yPage < 0){
					$this.css({"top":positionY-Y});
				}
				if(yPage > faHeight){
					$this.css({"top":faHeight+positionY-Y});
				}
			}
			if(movePosition.toLowerCase() == "x"){
				thisXMove();
			}else if(movePosition.toLowerCase() == "y"){
				thisYMove();
			}else if(movePosition.toLowerCase() == 'both'){
			    if(moveOutEnable){
				    thisAllMoveOutEnable();
			    }else{
			        thisAllMove();
			    }
			}
		});
		//添加以下两行，使新添加的元素总是在最顶层
		//father.children().css({"zIndex":"0"});
		$this.css({"zIndex":++dialogZindex});
    }
}); 
/*---来自drag.js end---------------*/


/*-------弹出框显示------------------------------*/
//通过全局变量获取下一个id，防止id重复
var autoID = 1000;
//弹出框
function hmyDialog(pm){
    var defaults = {
        width:400,
	    height:300,
	    content:""
    };
    var param = $.extend({},defaults,pm);
    var id=param.id,width=param.width,height=param.height,name=param.name,img=param.img;
	var posX=100,posY=40,posorder=0;
	//定义弹出框的位置
	$(".hmy_d_open").each(function(){
		if($(this).css("z-index")==dialogZindex){
			var posX1 = $(this).position().left+40;
			var posY1 = $(this).position().top+40;
			if((posX1+width)<=$(".desk_body").width()&&(posY1+height)<=$("body").height()){
				posX = $(this).position().left+40;
				posY = $(this).position().top+40;
			}else{
				posX = 100-(++posorder*20);
				posY = 40+(++posorder*20);
				if(posorder>5)posorder=0;
			}
		}
	});
	var dom = 
		$("<div id='"+id+"' class='hmy_d_open' style='top:"+posY+"px;left:"+posX+"px;width:"+width+"px;height:"+height+"px;'>"+
			"<div class='hmy_d_title'>&nbsp&nbsp<img class='hmy_d_title_img' draggable=\"false\" ondragstart=\"return false;\" src='"+img+"' />&nbsp&nbsp<span class='hmy_d_title_name'>"+name+"</span>"+
				"<a onclick='dialogMinHide($(this).parent().parent());' class=\"hmy_d_min\"></a>"+
				"<a onclick='dialogMax($(this))' class=\"hmy_d_max\"></a>"+
				"<a onclick='dialogClose($(this))' class=\"hmy_d_close\"></a>"+
				"<div class='hmy_d_mask'></div>"+
			"</div>"+
			"<div on_mouse_up='testcallback' class='hmy_d_content on_mouse_up'>"+param.content+"</div>"+
		"</div>");
	$("body").append(dom);
	$(".desk_foot").append('<div id="desk_foot'+id+'" onclick="dialogMin($(\'#'+id+'\'))" class="desk_foot_tab"><img class="desk_foot_tab_img" src="'+img+'" /><span class="desk_foot_tab_name">'+name+'</span></div>');
	
	$(".desk_foot_tab").removeClass("desk_foot_tab_active");
	$("#desk_foot"+id).addClass("desk_foot_tab_active");
	
	//设置可以拖拽移动
	dom.dragging({move : 'both',randomPosition : false ,hander:'.hmy_d_title'});
	dom.find(".hmy_d_title").mousedown();//模拟点击，置顶
	//拖拽大小
	hmy_drag(id);
}
//测试图标拖动回调
function testcallback(elem,drag_elems){
    console.log(elem);
    drag_elems.each(function(){
        console.log($(this).attr("elem_id"));
    });
    
}
//桌面图标拖动动作触发回调
$(function(){
	$("body").delegate(".on_mouse_up","mouseup",function(e){
		if(drag_hdi_ismove){
			var up = $(this).attr("on_mouse_up");
			if(up!=null){
				window[up]($(this),drag_hdi_elem);
			}
			/*drag_hdi_elem.each(function(){
                var c = $("#"+$(this).attr("elem_id")).clone().attr("id","c"+$(this).attr("elem_id"));
                c.appendTo(up);
            });*/
		};
		$(this).parent().find(".hmy_d_title").mousedown();
	});
});
//对话框关闭
function dialogClose(elem){
	elem.parent().parent().remove();
	$("#desk_foot"+elem.parent().parent().attr("id")).remove();
}
//对话框全屏切换按钮
function dialogMax(elem){
	elem.parent().mousedown();
	var p2 = elem.parent().parent();
	if(p2.width()==p2.parent().width()){
		p2.css("left",p2.attr("t_left"));
		p2.css("top",p2.attr("t_top"));
		p2.width(p2.attr("t_width"));
		p2.height(p2.attr("t_height"));
		p2.find(".hmy_d_drag").css("display","block");
		p2.find(".hmy_d_mask").hide();
	}else{
		p2.attr("t_left",p2.css("left"));
		p2.attr("t_top",p2.css("top"));
		p2.attr("t_width",p2.css("width"));
		p2.attr("t_height",p2.css("height"));
		p2.css("left","0px");
		p2.css("top","0px");
		p2.width("100%");
		p2.height("calc(100% - 31px)");
		p2.find(".hmy_d_drag").css("display","none");
		p2.find(".hmy_d_mask").show();
	}
	$(".desk_foot_tab").removeClass("desk_foot_tab_active");
    $("#desk_foot"+p2.attr("id")).addClass("desk_foot_tab_active");
}
//窗口是否最小化是否激活状态切换显示
function dialogMin(elem){
    $(".desk_foot_tab").removeClass("desk_foot_tab_active");
	var p2 = elem;
	if(p2.height()==0||(p2.css("z-index")!=dialogZindex)){
	    dialogMinShow(p2);
	}else{
	    dialogMinHide(p2);
	}
    return false;
}
//窗口最小化隐藏显示
function dialogMinHide(p2){
    p2.find(".hmy_d_title").mousedown();
    var tabp = $("#desk_foot"+p2.attr("id"));
	p2.attr("min_top",p2.css("top"));
	p2.attr("min_left",p2.css("left"));
	p2.attr("min_width",p2.css("width"));
	p2.attr("min_height",p2.css("height"))
    p2.animate({top:tabp.offset().top+"px",opacity:'0',height:0,left:tabp.offset().left+"px",width:tabp.css("width")},"fast",function(){
        p2.hide();
    });
}
//窗口从最小化恢复显示
function dialogMinShow(p2){
    p2.find(".hmy_d_title").mousedown();
    p2.show();
    p2.animate({top:p2.attr("min_top"),opacity:'1',height:p2.attr("min_height"),left:p2.attr("min_left"),width:p2.attr("min_width")},"fast");
    p2.find(".hmy_d_title").mousedown();
    $("#desk_foot"+p2.attr("id")).addClass("desk_foot_tab_active");
}
var dragelem = null;//记录当前拖动改变大小的元素
$(function(){
	//底部tab状态绑定到窗口（窗口状态是和title绑定的）
    $("body").delegate(".hmy_d_title","click",function(e){
        if($(e.target).hasClass("hmy_d_title")){
            $(".desk_foot_tab").removeClass("desk_foot_tab_active");
            $("#desk_foot"+$(this).parent().attr("id")).addClass("desk_foot_tab_active");
        }
	});
    //改变弹出窗口大小准备
	$("body").delegate(".hmy_d_drag","mousedown",function(){
		dragelem = $(this);
		$(this).parent().find(".hmy_d_title").mousedown();
		$("#window_mask").show();//遮罩-拖动窗口大小时防止受到ifame影响
	});
	//改变弹出窗口结束
	$(window).mouseup(function(e){
		dragelem = null;
		$("#window_mask").hide();//遮罩-拖动窗口大小时防止受到ifame影响
	});
	//改变弹出窗口大小
	$(window).mousemove(function(e){
		if(dragelem!=null){
			var e=e||window.event;
			var item = dragelem.parent();
			var setwith = e.pageX-item.position().left-2;
			var setheight = e.pageY-item.position().top-2;
			setwith = setwith>300?setwith:300;
			setheight = setheight>200?setheight:200;
			if(dragelem.hasClass("hmy_d_drag_1")){
				dragelem.css("left",setwith+"px");
				item.css("width",(setwith+7)+"px");
				item.find(".hmy_d_drag_3").css("left",setwith+"px");
			}else if(dragelem.hasClass("hmy_d_drag_2")){
				dragelem.css("top",setheight+"px");
				item.css("height",(setheight+7)+"px");
				item.find(".hmy_d_drag_3").css("top",setheight+"px");
			}else if(dragelem.hasClass("hmy_d_drag_3")){
				item.css("height",(setheight+7)+"px");
				item.css("width",(setwith+7)+"px");
				
				item.find(".hmy_d_drag_3").css("left",setwith+"px");
				item.find(".hmy_d_drag_3").css("top",setheight+"px");
			 	// Style刷新
				item.find(".hmy_d_drag_1").css("left",setwith+"px");
				item.find(".hmy_d_drag_2").css("top",setheight+"px");
			}
		}
	});
});
//拖拽改变大小
function hmy_drag(id){
	$("#"+id).append("<div class='hmy_d_drag hmy_d_drag_1'></div>"+
				"<div class='hmy_d_drag hmy_d_drag_2'></div>"+
				"<div class='hmy_d_drag hmy_d_drag_3'></div>");
}
/*-------弹出框显示------------------------------*/
/*-------桌面图标显示------------------------------*/
var hdi1 = null;

//初始化桌面图标
function hmy_d_ico_show_init(icons){
	hmy_d_ico_show(icons);
	$(".desk_body").resize(function () {          //当浏览器大小变化时
		hmy_d_ico_sort();//刷新图标位置
	});
	$(".desk_body").click(function(){//点击桌面，取消所有图标选中状态
		$(".hmy_d_ico").removeClass("hmy_d_ico_active");
	});
	$(".hmy_d_ico").click(function(e){//点击图标和按键组合，改变图标状态
	    if(!e.shiftKey){
	        hdi1 = null;
	    }
	    if(e.ctrlKey){
		    $(this).toggleClass("hmy_d_ico_active");
	    }else if(e.shiftKey){
	        var hdilast = $(".hmy_d_ico_active:last");
	        if(hdilast==null){
	            $(this).addClass("hmy_d_ico_active");
	            hdi1 = $(this);
	        }else{
	            hdi1 = hdi1!=null?hdi1:hdilast;
  		    $(".hmy_d_ico_active").removeClass("hmy_d_ico_active");
	            var hdi1_num = hdi1.attr("num"),this_num = $(this).attr("num");
	            var min = (hdi1_num>this_num?this_num:hdi1_num),max = (hdi1_num<this_num?this_num:hdi1_num);
	            for(var i=min;i<=max;i++){
	                $("#hdi"+i).addClass("hmy_d_ico_active");
	            }
	        }
	    }else{
		    $(".hmy_d_ico").removeClass("hmy_d_ico_active");
		    $(this).addClass("hmy_d_ico_active");
	    }
		return false;
	});
}
//根据数据生成桌面图标，并绑定双击动作
var hmy_d_icos_map = {} ;
function hmy_d_ico_show(hmy_d_icos){
	for (var i = 0; i < hmy_d_icos.length; i++) {
	    var dom = 
	        $("<div id='hdi"+i+"' class='hmy_d_ico' num='"+i+"' hdidata='"+JSON.stringify(hmy_d_icos[i])+"'>"+
				"<div class='hmy_d_ico_img'><img draggable=\"false\" ondragstart=\"return false;\" class='hmy_d_ico_img_show' src='"+hmy_d_icos[i].img+"'/></div>"+
				"<div class='hmy_d_ico_name'>"+hmy_d_icos[i].name+"</div>"+
			"</div>");
		$(".desk_body").append(dom);
		dom.dblclick(function(){
			//1.load加载url;2.iframe加载url;3.script执行脚本;4.快捷方式（实现方式未知）
		    if($("#dialog"+$(this).attr("id")).length>0){
		    	//如果窗口已存在，执行显示置顶
		        dialogMinShow($("#dialog"+$(this).attr("id")));
		    }else{
		    	//如果窗口不存在，弹出新窗口
		    	var thisid = $(this).attr("id");
    		    var data = hmy_d_icos_map[thisid];
    		    var content = "";
    		    if(data.type==1){
    		    	$.get(data.content,function(html){
    		    		//弹出新窗口
    	        		hmyDialog({
    	        		    id:"dialog"+thisid,
    	        		    img : data.img,
    	        		    name: data.name,
    	        		    width: data.width,
    	        		    height: data.height,
    	        		    content: html
    	        		});
    		    	});
    		    	return false;
    		    }else if(data.type==2){
    		    	
    		    	content = '<iframe src="'+data.content+'" frameborder="0" allowtransparency="true" allowfullscreen="true" webkitallowfullscreen="true" mozallowfullscreen="true" style="width: 100%; height: 100%; border: 0px;"></iframe>';
    		    }else if(data.type==3){
    		    	content = "<script>"+data.content+"</script>"
    		    	$("head").append(content);
    		    	return false;
    		    }else if(data.type==4){
    		    	content = "快捷方式"+data.content
    		    }
        		//弹出新窗口
        		hmyDialog({
        		    id:"dialog"+$(this).attr("id"),
        		    img : data.img,
        		    name: data.name,
        		    width: data.width,
        		    height: data.height,
        		    content: content
        		});
		    }
    		return false;
    	});
		//临时记录图标对应数据
		hmy_d_icos_map["hdi"+i]=hmy_d_icos[i];
	}
	hmy_d_ico_sort();
}
//图标位置刷新
function hmy_d_ico_sort(){
	var hmy_d_ico_dom = $(".hmy_d_ico");
	var left=0,top=0;
	for (var i = 0; i < hmy_d_ico_dom.length; i++) {
		$(hmy_d_ico_dom[i]).css("top",110*top+15)
		$(hmy_d_ico_dom[i]).css("left",90*left+15)
		if($(".desk_body").height()>(110*top+230)){
			top++;
		}else{
			top=0;left++;
		}
	}
}
/*-------桌面图标显示------------------------------*/
/*-----------拖动图标-----------*/
var drag_hdi = false,drag_hdi_elem = null,drag_hdi_ismove=false;
$(function(){
    var cX11 = 0,cY11 = 0;
    //推动图标初始化
	$("body").delegate(".hmy_d_ico","mousedown",function(e){
		cX11 = e.pageX;cY11 = e.pageY;
		drag_hdi = true;
		if(!e.shiftKey&&!e.ctrlKey&&!$(this).hasClass("hmy_d_ico_active")){
			$(".hmy_d_ico").removeClass("hmy_d_ico_active");
			$(this).addClass("hmy_d_ico_active");
		}
	});
    //拖动图标影子跟随鼠标
    $(document).mousemove(function(e){
        if(drag_hdi){
            var cX12 = e.pageX,cY12 = e.pageY;
            if(drag_hdi_elem==null){
                drag_hdi_elem = $(".hmy_d_ico_active").clone();
                drag_hdi_elem.each(function(){
                    $(this).attr("elem_id", $(this).attr("id"));
                    $(this).removeAttr("id");
                    $(this).css({zIndex:9999999,opacity:0.5,pointerEvents:"none"});
                    $(this).hide();
                });
                $("body").append(drag_hdi_elem);
            }else{
                drag_hdi_elem.each(function(){
                    $(this).show();
                    $(this).css({
                        top:cY12-cY11+$("#"+$(this).attr("elem_id")).offset().top,
                        left:cX12-cX11+$("#"+$(this).attr("elem_id")).offset().left
                    });
                });
                drag_hdi_ismove = true;
            }
        }
    });
    //拖动图标结束
    $(document).mouseup(function(e){
		if(drag_hdi_elem!=null){
    		drag_hdi_elem.remove();
    		drag_hdi_elem = null;
		}
		drag_hdi = false;
        drag_hdi_ismove = false;
	});
});
/*-----------拖动图标-----------*/
/*-------拖动选区选择图标------------------------------*/
$(function(){
    var cX1 = 0,cY1 = 0,cShow = false;
    //拖动选择图标初始化
    $("body").delegate(".desk_body","mousedown",function(e){
    	if($(e.target).hasClass("desk_body")){//排除内部元素被点击的情况
    		cX1 = e.pageX;cY1 = e.pageY;
    		cShow = true;//启动图标选择区
    		hdi1 = null;//清除shift图标选择起始值
    	}
    	desk_home_hide();//关闭home
	});
    //生成选区，并选中图标
    $(document).mousemove(function(e){
		if(cShow){
            var cX2 = e.pageX,cY2 = e.pageY;
            if($("#Icoselected").length==0){
                $("body").append("<div id='Icoselected'></div>");
            }
            cX2=cX2>=($(".desk_body").width()-2)?($(".desk_body").width()-2):cX2;
            cY2=cY2>=($(".desk_body").height()-2)?($(".desk_body").height()-2):cY2;
            var co = $("#Icoselected");
            if(cX2>cX1){
                co.css("left",cX1);
                co.css("width",cX2-cX1);
            }else{
                co.css("left",cX2);
                co.css("width",cX1-cX2);
            }
            if(cY2>cY1){
                co.css("top",cY1);
                co.css("height",cY2-cY1);
            }else{
                co.css("top",cY2);
                co.css("height",cY1-cY2);
            }
            //选中选取内的图标
            var hmy_d_ico_dom = $(".hmy_d_ico");
        	for (var i = 0; i < hmy_d_ico_dom.length; i++) {
        	    var dtop = $(hmy_d_ico_dom[i]).position().top;
        	    var dleft = $(hmy_d_ico_dom[i]).position().left;
        	    var dwidth = $(hmy_d_ico_dom[i]).width();
        	    var dheight = $(hmy_d_ico_dom[i]).height();
        	    if(((dtop>cY2&&dtop<cY1)||
        	        (dtop>cY1&&dtop<cY2)||
        	        ((dtop+dheight)>cY2&&(dtop+dheight)<cY1)||
        	        ((dtop+dheight)>cY1&&(dtop+dheight)<cY2))&&
        	        ((dleft>cX1&&dleft<cX2)||
        	        (dleft>cX2&&dleft<cX1)||
        	        ((dleft+dwidth)>cX1&&(dleft+dwidth)<cX2)||
        	        ((dleft+dwidth)>cX2&&(dleft+dwidth)<cX1))
        	    ){
        	        $(hmy_d_ico_dom[i]).addClass("hmy_d_ico_active");
        	    }else{
        	        $(hmy_d_ico_dom[i]).removeClass("hmy_d_ico_active");
        	    }
        	} 
		}
	});
    //鼠标拖动选区结束
	$(document).mouseup(function(e){
		cShow = false;
		if($("#Icoselected")!=null){
            $("#Icoselected").remove();
        }
	});
});
/*-------拖动选择------------------------------*/
/*-------home显示---------*/
$(function(){
	//点击home图标，home面板显示切换
    $("#desk_home").click(function(){
        if($("#desk_home_panel").height()==0||$("#desk_home_panel").css("z-index")!=dialogZindex){
            desk_home_show();
        }else{
            desk_home_hide();
        }
    });
    //点击面板使面板置顶
     $("#desk_home_panel").click(function(){
         desk_home_show();
     });
});
//home面板显示并制定
function desk_home_show(){
    $(".desk_foot_tab_active").removeClass("desk_foot_tab_active");
    $("#desk_home_panel").animate({width:"300px",height:'400px',opacity:'1'},"fast");
    $("#desk_home").addClass("desk_home_active");
    $("#desk_home_panel").css("z-index",$("#desk_home_panel").css("z-index")==dialogZindex?dialogZindex:++dialogZindex);
}
//home面板隐藏
function desk_home_hide(){
    $(".desk_foot_tab_active").removeClass("desk_foot_tab_active");
    $("#desk_home_panel").animate({width:"34px",height:'0px',opacity:'0'},"fast");
    $("#desk_home").removeClass("desk_home_active");
}
/*-------home显示---------*/
/*-------可拖动布局-----*/
var drag_layout_side = null;//记录被拖动的布局
$(function(){
	//初始化要拖动的布局
	$("body").delegate(".drag_layout_side","mousedown",function(e){
		drag_layout_side = $(this);
	});
	 $(document).mousemove(function(e){
		 if(drag_layout_side!=null){
            var cX2 = e.pageX,cY2 = e.pageY;
            var dright = drag_layout_side.parent();
            var delem = dright.parent();
            var dleft = delem.find(".drag_layout_left");
            var delem_left = delem.offset().left;
            var left = (cX2-delem_left)<5?5:(cX2-delem_left)>delem.width()-15?delem.width()-15:(cX2-delem_left);
            dleft.css("width",left+"px");
            dright.css("width","calc(100% - "+(left+1)+"px)");
            
		 }
	 });
	 //布局拖动结束
	 $(document).mouseup(function(e){
		 drag_layout_side = null;
	 });
});
/*-----菜单动作---------*/
$(function(){
	$("body").delegate(".nav li","click",function(e){
		var parent = $(this).parent();
		parent.children("li").removeClass("active");
		$(this).addClass("active");
	});
});
//以id选定元素显示url内容
function showcontentinid(id,url){
	$("#"+id).load(url);
}
//ajax submit
$("body").delegate("form","submit",function(e){
	
});